package com.crm.business.admin.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.crm.business.admin.service.AdminMessageService;
import com.crm.business.admin.service.IAdminMessageService;
import com.crm.common.ka.core.feign.admin.entity.AdminMessage;
import com.crm.common.ka.core.feign.admin.entity.AdminMessageBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminMessageCallServiceImpl implements AdminMessageService {

    @Autowired
    private IAdminMessageService messageService;



    public AdminMessage save(com.crm.common.ka.core.feign.admin.entity.AdminMessage adminMessage){
        AdminMessage adminMessage1 = BeanUtil.copyProperties(adminMessage, AdminMessage.class);
        if (adminMessage.getCreateTime() != null){
            adminMessage1.setCreateTime(adminMessage.getCreateTime());
        }
        messageService.save(adminMessage1);
        return adminMessage1;
    }

    public AdminMessage update(com.crm.common.ka.core.feign.admin.entity.AdminMessage adminMessage){
        AdminMessage adminMessage1 = BeanUtil.copyProperties(adminMessage, AdminMessage.class);
        if (adminMessage.getCreateTime() != null){
            adminMessage1.setCreateTime(adminMessage.getCreateTime());
        }
        messageService.updateById(adminMessage1);
        return adminMessage1;
    }

    public AdminMessage getById(Long messageId){
        AdminMessage adminMessage = messageService.getById(messageId);
        return adminMessage;
    }

    public AdminMessage sendMessage(AdminMessageBO adminMessageBO){
        messageService.addMessage(adminMessageBO);
        return new AdminMessage();
    }

    public void deleteEventMessage(Integer eventId){
        messageService.deleteEventMessage(eventId);
    }

    public void deleteByLabel(Integer label){
        messageService.deleteByLabel(label);
    }
}
